/**
 * @description 全局公共模块数据的 store
 */

import { defineStore } from 'pinia'

export default defineStore('commonStore', {
    state: () => ({ age: 11 }),
    actions: {
        async changeAge(num?: number) {
            if (num) {
                const p1: Promise<number> = new Promise(res => setTimeout(() => res(1), 2000));
                this.age = await p1;
                setTimeout(() => queueMicrotask(() => this.age = 222), 2000)
            } else {
                this.age += 1
            }
        }
    }
})